# Maintainer: Daniel Micay <danielmicay@gmail.com>
# Contributor: Mikael Eriksson <mikael_eriksson@miffe.org>
# Originally by: Denis Smirnov <detanator@gmail.com>

_pkgname=igt-gpu-tools
pkgname=intel-gpu-tools
pkgver=1.27
pkgrel=2
pkgdesc="Tools for development and testing of the Intel DRM driver"
arch=(loong64 x86_64)
license=(MIT)
url='https://gitlab.freedesktop.org/drm/igt-gpu-tools'
depends=(libdrm libpciaccess cairo python xorg-xrandr libprocps kmod libxv libunwind peg systemd)
makedepends=(swig gtk-doc xorg-util-macros xorgproto meson)
source=(https://xorg.freedesktop.org/releases/individual/app/${_pkgname}-$pkgver.tar.xz{,.sig}
	remove-race-in-creating-batch-buffers.patch
	remove-crc32-table-from-common-section.patch)
sha512sums=('43728c1981862f48180652849fbf04e36f976ae39a20f166fd5b4413ad3d682f7eea5db27c53d48d88d516577b053a6cc5afe000d1cad19ba65dedc248edf4a6'
            'SKIP'
            '91abc467d594fd97784f5843853c53bd812445f956c0f299a1127a2d758416485a7bb5c9bda764c7ce2ce133b9aa4bb6076a20a307261a18274d7f61623f142f'
            '2053f4e30752bd6ebf735ba5f629f68899c31b2984d5a0fcfc8c11bdd09223308f9f5c7bb3bd8dfe5c57341ef89ccb87235a5f0c14e2439d7451d5eb4cfa845a')
validpgpkeys=('775965B85650195ACE77E18D7370055DB74C2475'
              'E1996E8A119F43C4BA2BE889D8C620766EA3F69D')

prepare() {
  mkdir -p build
  cd igt-gpu-tools-${pkgver}
  patch -Np1 -i ${srcdir}/remove-race-in-creating-batch-buffers.patch
  patch -Np1 -i ${srcdir}/remove-crc32-table-from-common-section.patch
}

build() {
  cd build
  meson ../$_pkgname-$pkgver \
    --prefix=/usr \
    --libexecdir=/usr/lib

  ninja
}

check() {
  cd build
  ninja test
}

package() {
  cd build
  DESTDIR="$pkgdir" ninja install

  cd ../$_pkgname-$pkgver
  install -Dm644 COPYING "$pkgdir/usr/share/licenses/${pkgname}/COPYING"
}
